library(plotly)
library(here)
library(tidyverse)
library(ggplot2)
library(dplyr)
library(magick)
library(rmdformats)Breed_Traits <- read_csv(here("Data","Breed Traits.csv")) # Load first data set
View(Breed_Traits)
AKC_Breed_Info <- read_csv(here("Data","AKC Breed Info.csv")) # Load second data set
View(AKC_Breed_Info)long <- Breed_Traits %>%
pivot_longer(cols = c(`Affectionate With Family`,`Good With Young Children`, `Good With Other Dogs`, `Shedding Level`, `Coat Grooming Frequency`, `Drooling Level`, `Openness To Strangers`, `Playfulness Level`, `Watchdog/Protective Nature`, `Adaptability Level`, `Trainability Level`, `Energy Level`, `Barking Level`, `Mental Stimulation Needs`), # variables in the new column
names_to = 'Traits', # new name of the column
values_to = 'Values') # name of the column
View(long)Traits_long <- long %>% # graph with this data
plot_ly(x = ~ `Breed Group`,
y = ~ Values,
color = ~ Traits,
type = "bar", # bar graph
marker = list(color = rainbow(nrow(long)))) %>% # bar graph is colored by rainbow
layout(title = 'Breed vs. Traits', # add a title
xanchor = 'center', # center the title
yanchor = 'top',
font = list(color = "darkorchid"), # change title color
plot_bgcolor = "white", # made background white
paper_bgcolor = "lavender", # paper background color
xaxis = list(title = 'Breed Group', # label x axis
tickangle = -45, # angle the x axis
color = "darkorchid", # color x axis
size = 15),# make the x axis smaller
yaxis = list(title = 'Rank', # label y axis
color = "darkorchid"), # color of y axis title
legend = list(title = list(text = '<b> Traits </b>', # rename legend
font = list(color = "darkorchid"), # change legend color
xanchor = 'center', # center the legend
yanchor = 'top')))
Traits_longcoat_filtered <- Breed_Traits %>%
filter(`Breed Group` %in% c("Hound","Sporting")) %>% # filter out breed group
filter(`Coat Type` %in% c("Smooth","Double")) %>%# filter out coat preference
filter(`Affectionate With Family` >= 3)%>%
filter(`Good With Other Dogs` >= 3) %>%
filter(`Trainability Level` >=3) %>%
filter(`Adaptability Level` >=3) %>%
filter(`Coat Length` == "Short")
View(coat_filtered)table <- coat_filtered %>%
plot_ly(
type = 'table',
columnwidth = c(80),
header = list(
values = c('<b>Breed</b>','<b>Affectionate With Family</b>','<b>Good With Other Dogs</b>','<b>Adaptability Level</b>','<b>Trainability Level</b>','<b>Coat Type</b>','<b>Coat Length</b>'),
line = list(color = '#506784'),
fill = list(color = '#119DFF'),
align = c('left','center'),
font = list(color = 'white', size = 12)
),
cells = list(
values = rbind(
c('Retrievers (Labrador)', 'Beagles', 'Pointers (German Shorthaired)', 'Dachshunds', 'Brittanys','Vizslas','Basset Hounds','Weimaraners','Rhodesian Ridgebacks','Bloodhounds','Whippets','Pointers','Black and Tan Coonhounds
','Bluetick Coonhounds','Greyhounds','Salukis','Redbone Coonhounds','Treeing Walker Coonhounds','Cirnechi dell’Etna','Pharaoh Hounds','American English Coonhounds','Sloughis','Harriers','American Foxhounds','English Foxhounds'),
c(5,3,5,5,3,5,3,5,5,4,5,5,4,3,4,5,5,5,4,5,3,4,5,3,5),
c(3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5),
c(4,4,3,3,3,4,4,3,5,4,4,5,4,3,3,4,4,3,4,4,3,3,4,3,4),
c(5,4,4,3,3,5,4,5,5,3,4,5,3,3,3,5,3,4,3,5,4,3,4,3,4),
c("Smooth","Smooth","Smooth","Smooth","Smooth","Smooth","Smooth","Double","Smooth","Smooth","Smooth","Double","Smooth","Smooth","Smooth","Smooth","Smooth","Smooth","Smooth","Smooth","Smooth","Smooth","Double","Smooth","Double"),
c("Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short","Short")),
line = list(color = '#506784'),
fill = list(color = c('#25FEFD', 'white')),
align = c('left', 'center'),
font = list(color = c('#506784'), size = 12)
))
tableweight_f <- AKC_Breed_Info %>%
drop_na() %>%
filter(Breed %in% c("Whippet","Vizsla","Rhodesian Ridgeback","Labrador Retriever","German Shorthaired Pointer","Pharaoh Hound","Harrier","English Foxhound","Black And Tan Coonhound","Basset Hound","Beagle","Dachshund","Brittany","Weimarener","Bloodhound","Whippet","Basenji","Pointer","Greyhound","Redbone Coonhound")) %>% # filter data to be universal
filter(weight_low_lbs >= 45) %>% # look at weights greater than 45 lbs
filter(weight_high_lbs <= 100) # weight less than 100 lbs
View(weight_f)weight <- weight_f %>% # plot filtered data
plot_ly(x = ~ weight_low_lbs,
y = ~weight_high_lbs,
type = "scatter", # type of data
mode = "markers",
color = ~Breed, # color by
colors = "Paired", # color pattern
size = 22, # size of dot
alpha = 1) %>%
layout(title = 'Breed vs. Weight', # title of plot
font = list(color = "navy"), # title color
plot_bgcolor = "white",# plot color
paper_bgcolor = "lightcyan", # background color
xaxis = list(title = 'Low Weight Range', # x axis title
tickangle = -45, # angle x axis
color = "navy"), # color x axis
yaxis = list(title = 'High Weight Range', # y axis title
color = "navy"), # y axis color
legend = list(title = list(text = '<b> Breed </b>', # legend title
font = list(color = "navy"), # legend color
xanchor = 'center', # center title
yanchor = 'top')))
weightheight_f <- weight_f %>%
filter(height_low_inches >= 21) %>%
filter(height_high_inches <= 26)
View(height_f)height <- height_f%>% # plot filtered data
plot_ly(x = ~ height_low_inches,
y = ~height_high_inches,
type = "scatter", # type of data
mode = "markers",
color = ~Breed, # color by
colors = "Paired", # color pattern
size = 22, # size of dot
alpha = 1) %>%
layout(title = 'Breed vs. Height', # title of plot
font = list(color = "navy"), # title color
plot_bgcolor = "white",# plot color
paper_bgcolor = "lightcyan", # background color
xaxis = list(title = 'Low Height Range', # x axis title
tickangle = -45, # angle x axis
color = "navy"), # color x axis
yaxis = list(title = 'High Height Range', # y axis title
color = "navy"), # y axis color
legend = list(title = list(text = '<b> Breed </b>', # legend title
font = list(color = "navy"), # legend color
xanchor = 'center', # center title
yanchor = 'top')))
heighttrait_filter <- long %>%
filter(Breed %in% c("English Foxhounds","Retrievers (Labrador)","Pharaoh Hounds","Vizslas")) %>%
filter(Traits %in% c("Trainability Level","Adaptability Level","Good With Other Dogs","Affectionate With Family"))
View(trait_filter)final <- trait_filter %>% # data used
plot_ly(x = ~ Traits,
y = ~Values,
type = "bar", # type of graph
mode = "markers",
color = ~Breed, # color by
colors = "Dark2") %>% # color pattern
layout(title = 'Vizsla vs. Greyhounds', # plot title
font = list(color = "darkred"), # title color
plot_bgcolor = "bisque", # color of plot
paper_bgcolor = "bisque", # color of background
xaxis = list(title = 'Traits', # x axis title
tickangle = -45, # angle x axis
color = "darkred"), # x axis color
yaxis = list(title = 'Rank',# y axis title
color = "darkred"), # y axis color
legend = list(title = list(text = '<b> Breed </b>', # legend title
font = list(color = "darkred"), # legend color
xanchor = 'center', # title centered
yanchor = 'top')))
finalVizsla <- image_read("https://images.ctfassets.net/m5ehn3s5t7ec/wp-image-198422/0e0fe308ed17ab3af5f3c8f2db288667/Vizsla-Dog-Breed-Information.jpg") # read in image
image_border(Vizsla, color = "peachpuff",
geometry = "8x10") %>% # Add a border
image_annotate("Vizsla", font = 'Palatino',
size = 50,
gravity = "southwest",
color = "black",
boxcolor = "peachpuff") # add text box # References